from webLib.LibFileType import LibFileType


class Lib(object):
    def __init__(self, name, lib_files={}):
        self._name = name
        self._libFiles = lib_files

    @property
    def libname(self):
        return self._name

    @libname.setter
    def libname(self, libname):
        self._name = libname

    @staticmethod
    def print_js(lib_file):
        return '''<script src="{path}" type="text/javascript"></script>\n'''.format(path=lib_file.path)

    @staticmethod
    def print_css(lib_file):
        return '''<link href="{path}" rel="stylesheet" />\n'''.format(path=lib_file.path)

    def print_lib_files(self):
        result = ''
        for lib_file in self._libFiles:
            if lib_file.file_type == LibFileType.JS:
                result += Lib.print_js(lib_file)
            elif lib_file.file_type == LibFileType.CSS:
                result += Lib.print_css(lib_file)
        return result



